package com.xuexiang.xuidemo.slice;

import com.xuexiang.xuidemo.ResourceTable;
import com.xuexiang.xuidemo.slice.edittext.CustomEditAbilitySlice;
import com.xuexiang.xuidemo.slice.edittext.EditStyleAbilitySlice;
import com.xuexiang.xuidemo.slice.edittext.MeterialEditAbilitySlice;
import com.xuexiang.xuidemo.slice.edittext.VeriftEditAbilitySlice;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.components.Image;
import ohos.agp.components.Text;

public class EditTextAbiliytSlice extends AbilitySlice implements Component.ClickedListener {

    private Button customEdit,editStyle,meterialEdit,veriftEdit;
    private Text text1,text2;


    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_edittext);
        initView();
    }

    private void initView(){
        customEdit = (Button) findComponentById(ResourceTable.Id_customEdit);
        editStyle = (Button) findComponentById(ResourceTable.Id_editStyle);
        meterialEdit = (Button) findComponentById(ResourceTable.Id_meterialEdit);
        veriftEdit = (Button) findComponentById(ResourceTable.Id_veriftEdit);
        text1 = (Text)findComponentById(ResourceTable.Id_text1);
        text2 = (Text)findComponentById(ResourceTable.Id_text2);
        customEdit.setClickedListener(this);
        editStyle.setClickedListener(this);
        meterialEdit.setClickedListener(this);
        veriftEdit.setClickedListener(this); Image backImage = (Image) findComponentById(ResourceTable.Id_backImage);
        backImage.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                terminate();
            }
        });
        text1.setClickedListener(this);
        text2.setClickedListener(this);


    }

    @Override
    public void onClick(Component component) {
        switch (component.getId()){
            case ResourceTable.Id_customEdit:
                present(new EditStyleAbilitySlice(),new Intent());
                break;
            case ResourceTable.Id_editStyle:
                present(new CustomEditAbilitySlice(),new Intent());
                break;
            case ResourceTable.Id_meterialEdit:
                present(new MeterialEditAbilitySlice(),new Intent());
                break;
            case ResourceTable.Id_veriftEdit:
                present(new VeriftEditAbilitySlice(),new Intent());
                break;
            case ResourceTable.Id_text1:
                present(new MeterialEditAbilitySlice(),new Intent());
                break;
            case ResourceTable.Id_text2:
                present(new VeriftEditAbilitySlice(),new Intent());
                break;
        }

    }
}
